<script setup lang="ts">
import { useRoute, useRouter, } from 'vue-router';
import { useMenuStore } from '@/stores/menu';
import { ref, watchEffect } from 'vue';
import { ElMessage } from 'element-plus';

const route = useRoute();
const router = useRouter();

const menuStore = useMenuStore();
const loading = ref(true);

/**
 * 作为路由未加载完成的中转页。加载完成，会自动跳转到目标页面
 */
watchEffect(() => {
    if (menuStore.remoteRouteLoaded) {
        loading.value = false;

        let params = route.params;
        if (!params || !params.to) {
            return;
        }

        let paramsJson = JSON.parse(params.to.toString());

        menuStore.menuDefaultActive = paramsJson.path;

        router.push({
            path: paramsJson.path,
            query: paramsJson.query,
            hash: paramsJson.hash
        });
    }
})
</script>

<template>
    <div v-loading.fullscreen="loading">
    </div>
</template>

<style lang="scss" scoped></style>